package com.ithe.shopweb.common;

import lombok.*;

/**
 * 功能：
 * 日期： 2024/5/21 23:42
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result {
    public static final String CODE_SUCCESS = "200";    //数据响应成功
    public static final String CODE_AUTH_ERROR = "401"; //身份验证失败
    public static final String CODE_SYS_ERROR = "500";  //服务响应异常

    private String code;    //响应结果
    private String msg;     //响应提示
    private Object data;    //响应数据

    public static Result success() {
        return new Result(CODE_SUCCESS, "请求成功", null);
    }

    public static Result success(Object data) {
        return new Result(CODE_SUCCESS, "请求成功", data);
    }

    public static Result error(String msg) {
        return new Result(CODE_AUTH_ERROR, msg, null);
    }

    public static Result error(String code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result error() {
        return new Result(CODE_SYS_ERROR, "系统错误", null);
    }

}
